package com.linkstec.bookshop.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.linkstec.bookshop.service.GoodsService;
import com.linkstec.bookshop.vo.GoodsVo;

/**
 * 
 * @ClassName:  GoodsController   商品的controller
 * @Description:TODO   
 * @author:  JGQiang
 * @date:   2018年11月26日 上午9:13:53
 */
@Controller
@RequestMapping("goods")
public class GoodsController {
	
	@Autowired
	private GoodsService goodsService;
	
	/**
	 * 
	 * @Description:TODO 跳转到商品详情页
	 * @author: JGQiang
	 * @date:   2018年11月26日 上午9:28:32    
	 * @param goodsId
	 * @return
	 */
	@RequestMapping(value="toGoodsDetail")
	public ModelAndView toGoodsDetail(int goodsId){
		ModelAndView mv =new ModelAndView();
		GoodsVo goodsDetail = new GoodsVo();
		try {
			goodsDetail = goodsService.findOneGoodsDetail(goodsId);
		} catch (Exception e) {
			e.printStackTrace();
		}
		mv.addObject("goods", goodsDetail);
		mv.setViewName("product");
		return mv;
	}

}
